#include<bits/stdc++.h>
using namespace std;
int T,n,a[200010];
long long sum;
priority_queue<int,vector<int>,greater<int> >q;
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>T;
    for(int i=1;i<=T;i++){
        cin>>n;
        for(int j=1;j<=n;j++){
            cin>>a[j];
            q.push(a[j]);

        }
        while(!q.empty()){
            int m=q.top();
            q.pop();
            if(q.empty()) break;
            if(m==q.top()){sum+=m;q.pop();}
            else q.pop();
            }



        cout<<sum<<endl;
        while(!q.empty()) q.pop();
        sum=0;
    }
return 0;}
